﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MetadataBasedConfig.POCO;

namespace MetadataBasedConfig
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Test();
        }


        #region Test Poco

        protected void Test()
        {
            EntityRepository<User> userRepository = (EntityRepository<User>)Global.ApplicationContext.GetObject("userRepository");
            var alUserss = userRepository.Excute(us => (from u in us where u.ID > 0 select u));
            var allUsers = userRepository.Excute(us => us.Where(u => u.ID > 0));
            var allUsersCount = userRepository.Excute(us => us.Count());
            EntityRepository<Tenant> tenantRepository = (EntityRepository<Tenant>)Global.ApplicationContext.GetObject("tenantRepository"); 
            try
            {
                Tenant tenant = new Tenant();
                tenant.Name = "dfddf";
                tenant.ID =1;
                tenantRepository.Update(tenant);
            }
            catch(Exception ex)
            {
            }
            try
            {
                Tenant tenant = tenantRepository.DbSet.Create();
                tenant.Name = "dfddf";
                tenant.ID = 1;
                tenantRepository.Update(tenant);
            }
            catch (Exception ex)
            {
            }
        }

        #endregion
    }
}